<?php

    function tvn_user_profile_email_exists($mail) {
        return (bool) db_select('users', 'u')->fields('u', array('uid'))->condition('u.mail', $mail)->execute()->fetchField();
    }

    function _tvn_user_transactions_data($uid, $limit = 50) {
        $query = db_select('tvn_transaction', 'tt')->extend('PagerDefault');
        $query->fields('tt');
        $query->condition('tt.uid', $uid);
        $query->limit($limit);
        return $query->execute();
    }